const sequelize = require('sequelize');

module.exports = app => {
    const { STRING, INTEGER, TEXT, BOOLEAN } = app.Sequelize;
    const Role = app.model.define('article', {
        id: { type: sequelize.INTEGER, primaryKey: true, autoIncrement: true },
        title: sequelize.STRING(1234),
        author: {
            type: STRING,
            defaultValue: '官方团队'
        },
        status: {
            type: STRING,
            defaultValue: 'publish', // publish-发布 unPublish-未发布 
        },
        preview: {
            type: STRING(1234),
        },
        toTop: { // 是否置顶
            type: BOOLEAN,
            allowNull: false,
            defaultValue: false,
        },
        autoImage: { // 是否自动生成缩略图
            type: BOOLEAN,
            defaultValue: true,
        },
        autoSummary: {
            type: BOOLEAN,
            defaultValue: true,
        },
        download: {
            type: BOOLEAN,
            defaultValue: true
        },
        content: {
            type: TEXT,
            allowNull: false,
        },
        articleId: {
            type: INTEGER,
            allowNull: false,
        },
        categoryId: {
            type: INTEGER,
            allowNull: false,
        },
        subCategoryId: {
            type: INTEGER
        },
        tags: {
            type: STRING(2048),
            allowNull: false,
        },
        downLinks: {
            type: STRING(2048)
        },
        summary: {
            type: TEXT,
            allowNull: false,
        }
    });

    return Role;
};